﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;

namespace UI
{
    public class FormBase : DevExpress.XtraEditors.XtraForm
    {
        public int UserID
        {
            get { return GlobalValues.UserID; }
        }

        public string UserName
        {
            get { return GlobalValues.UserName; }
        }

        public bool IsAdmin
        {
            get { return GlobalValues.IsAdmin; }
        }

        public int[] Departments
        {
            get { return GlobalValues.Departments; }
        }

        public void CommonError(Exception ex)
        {
            DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message, "Message");
        }

        public void CommonMessage(string content)
        {
            CommonMessage(content, "Message");
        }

        protected void CommonMessage(string content, string title)
        {
            DevExpress.XtraEditors.XtraMessageBox.Show(content, title);
        }

        protected bool CommonConfirm(string content, string title)
        {
            return DevExpress.XtraEditors.XtraMessageBox.Show(content, title, System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes;
        }

        protected void InitSession(DevExpress.Xpo.Session session)
        {
            session.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connect"].ConnectionString;
            session.Connect();
        }
    }
}
